﻿using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Business;
using Models;
//using Fnet.UserWS;

/// <summary>
/// Summary description for @base
/// </summary>
public class @base : System.Web.UI.Page {
    #region Sessions
    public string USERNAME {
        get { return Session["USERNAME"].ToString(); }
        set { Session["USERNAME"] = value; }
    }

    public int CLIENTID {
        get { return ToInt(Session["CLIENTID"].ToString()); }
        set { Session["CLIENTID"] = value; }
    }
    public int SUBCLIENTID {
        get { return ToInt(Session["SUBCLIENTID"].ToString()); }
        set { Session["SUBCLIENTID"] = value; }

    }
    public int MACHINEID {
        get { return ToInt(Session["MACHINEID"].ToString()); }
        set { Session["MACHINEID"] = value; }
    }
    public string MACHINENAME {
        get { return Session["MACHINENAME"].ToString(); }
        set { Session["MACHINENAME"] = value; }
    }
    public string SITENAME {
        get { return Session["SITENAME"].ToString(); }
        set { Session["SITENAME"] = value; }
    }
    public User UserDetails {
        get { return (User)Session["USERDETAILS"]; }
        set { Session["USERDETAILS"] = value; }
    }
    public Client ClientDetails {
        get { return (Client)Session["CLIENTDETAILS"]; }
        set { Session["CLIENTDETAILS"] = value; }
    }

    #endregion

    #region Casting
    public int ToInt(Object input) {
        return Convert.ToInt32(input);
    }
    #endregion
    #region Casting
    public int ToInt(string input) {
        if (input != "")
            return Int32.Parse(input);
        return 0;
    }
    #endregion

    #region Binding Property

    public void BindUserDetails() {
        User user = new User();
        UserServices us = new UserServices();

        user = us.GetUserByName(USERNAME);
        UserDetails = user;
        CLIENTID = user.ClientID;
    }


    public void BindClientDetails() {
        Client client = new Client();
        UserServices us = new UserServices();
        client = us.getClientByID(CLIENTID);
        // client.ClientID = CLIENTID;
        ClientDetails = client;
    }

    #endregion

}
